<template>
  <a @click="btnClick" class="tab-bar-item">
    <div v-if="!isActive"><slot name="item-icon"></slot></div>
    <div v-else><slot name="item-icon-active"></slot></div>
    <!-- <div :class="{ active: isActive }"></div> -->
    <div :style="activeStyle"><slot name="text"></slot></div>
  </a>
</template>

<script>
export default {
  name: "TabBarItem",
  props: {
    path: String,
    active: {
      type: String,
      default: "red",
    },
  },

  computed: {
    isActive() {
      return this.$route.path.indexOf(this.path) !== -1;
      //  return this.$route.path==this.path;
      // return this.$route.path.includes(this.path) == 1;
    },
    activeStyle() {
      return this.isActive ? { color: this.active } : {};
    },
  },
  mounted() {},

  methods: {
    btnClick() {
      this.$router.replace(this.path);
    },
  },
};
</script>

<style scoped>
.tab-bar-item {
  flex: 1;
  display: block;
  text-align: center;
  height: 49px;
  font-size: 14px;
}
a {
  display: block;
}
</style>
